<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('查看请款')" />
    <th:block th:include="include :: datetimepicker-css" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-fund-edit" th:object="${workRequestFund}">
            <input name="requestId" id="requestId" th:field="*{requestId}" type="hidden">
            <div class="form-group">    
                <label class="col-sm-3 control-label">联系人：</label>
                <div class="col-sm-8">
                    <input name="contacts" th:field="*{contacts}" class="form-control" type="text" >
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">请款总额：</label>
                <div class="col-sm-8">
                    <input name="fundAmount" th:field="*{fundAmount}" class="form-control" type="text" >
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">请款银行：</label>
                <div class="col-sm-8">
                    <select name="bankName" class="form-control m-b" th:with="type=${@dict.getType('work_bank')}">
                        <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" th:field="*{bankName}"></option>
                    </select>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">银行账号：</label>
                <div class="col-sm-8">
                    <input name="bankAccount" th:field="*{bankAccount}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">备注：</label>
                <div class="col-sm-8">
                    <textarea name="remark" class="form-control">[[*{remark}]]</textarea>
                </div>
            </div>
        </form>
        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table"></table>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: datetimepicker-js" />
    <script th:inline="javascript">
        var prefix = ctx + "work/fund";
        var paperTypeDatas = [[${@dict.getType('work_paper_type')}]];
        var platformDatas = [[${@dict.getType('work_platform')}]];
        var priceTypeDatas = [[${@dict.getType('work_price_type')}]];
        var paperStatusDatas = [[${@dict.getType('work_paper_status')}]];

        $("#form-fund-edit").validate({
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/edit", $('#form-fund-edit').serialize());
            }
        }

        $("input[name='requestTime']").datetimepicker({
            format: "yyyy-mm-dd",
            minView: "month",
            autoclose: true
        });
        function footerStyle(column) {
            return {
                actualPrice: {
                    css: {color: 'red', 'font-weight': 'normal'}
                },
                actualCost: {
                    css: {color: 'red', 'font-weight': 'normal'}
                }, cost: {
                    css: {color: 'red', 'font-weight': 'normal'}
                }, paperPrice: {
                    css: {color: 'red', 'font-weight': 'normal'}
                },
            }[column.field]
        }
        $(function () {
            var options = {
                url: ctx + "work/paper/requestlist/"+$('#requestId').val(),
                modalName: "稿件管理",
                showFooter: true,
                footerStyle: footerStyle,
                striped: true,
                columns: [
                    {
                        field: 'paperId',
                        title: '稿件ID',
                        width: 80,
                        footerFormatter: function (value) {
                            return "合计：";
                        }
                    },
                    {
                        field: 'paperStatus',
                        title: '状态',
                        formatter: function (value, row, index) {
                            return $.table.selectDictLabel(paperStatusDatas, value);
                        },
                        width: 100
                    },
                    {
                        field: 'paperType',
                        title: '稿件类型',
                        formatter: function (value, row, index) {
                            return $.table.selectDictLabel(paperTypeDatas, value);
                        },
                        width: 100

                    },
                    {
                        field: 'paperName',
                        title: '稿件名称',
                        colspan: 1,
                        width: 500,
                        widthUnit: 'px'

                    },
                    {
                        field: 'belong',
                        title: '稿件所属',
                        width: 80
                    },

                    {
                        field: 'customerName',
                        title: '客户名称',
                        width: 200

                    },
                    {
                        field: 'companyName',
                        title: '客户所属公司',
                        width: 200

                    }, {
                        field: 'createTime',
                        title: '登记时间',
                        width: 200
                    },
                    {
                        field: 'mediaName',
                        title: '媒体名称',
                        width: 200
                    },
                    {
                        field: 'platform',
                        title: '平台',
                        formatter: function (value, row, index) {
                            return $.table.selectDictLabel(platformDatas, value);
                        },
                        width: 100

                    },
                    {
                        field: 'mediaCreate',
                        title: '媒介',
                        width: 200

                    },
                    {
                        field: 'publishLink',
                        title: '刊登链接',
                        width: 200

                    },
                    {
                        field: 'publishDate',
                        title: '刊登时间',
                        width: 100,
                    },
                    {
                        field: 'paperPrice',
                        title: '稿件费',
                        width: 100,
                        footerFormatter: function (value) {
                            var sumBalance = 0;
                            for (var i in value) {
                                sumBalance += parseFloat(value[i].paperPrice);
                            }
                            return sumBalance;
                        }
                    },
                    {
                        field: 'flowPrice',
                        title: '刷量费',
                        width: 100

                    },
                    {
                        field: 'cost',
                        title: '成本',
                        width: 100,
                        footerFormatter: function (value) {
                            var sumBalance = 0;
                            for (var i in value) {
                                sumBalance += parseFloat(value[i].cost);
                            }
                            return sumBalance;
                        }
                    },
                    {
                        field: 'actualCost',
                        title: '实际成本',
                        width: 100,
                        footerFormatter: function (value) {
                            var sumBalance = 0;
                            for (var i in value) {
                                sumBalance += parseFloat(value[i].actualCost);
                            }
                            return sumBalance;
                        }
                    },
                    {
                        field: 'price',
                        title: '单价',
                        width: 100
                    },
                    {
                        field: 'words',
                        title: '字数',
                        width: 100
                    },
                    {
                        field: 'actualPrice',
                        title: '实际总价',
                        width: 100,
                        footerFormatter: function (value) {
                            var sumBalance = 0;
                            for (var i in value) {
                                sumBalance += parseFloat(value[i].actualPrice);
                            }
                            return sumBalance;
                        }
                    },
                    {
                        field: 'priceType',
                        title: '价格类型',
                        formatter: function (value, row, index) {
                            return $.table.selectDictLabel(priceTypeDatas, value);
                        },
                        width: 100
                    },
                    {
                        field: 'flowRemark',
                        title: '刷量备注',
                        width: 200
                    },
                    {
                        field: 'originalLink',
                        title: '原始链接',
                        width: 200
                    },
                    {
                        field: 'paybackPeriod',
                        title: '回款周期',
                        width: 100
                    },
                    {
                        field: 'remark',
                        title: '备注',
                        width: 200
                    }]
            };
            $.table.init(options);
        });
    </script>
</body>
</html>